package com.d0318;

public class ThreadYieldOne implements Runnable{
    String name;
    @Override
    public void run() {
        for (int i = 0; i <10 ; i++) {
            Thread.yield();//使进程进入就绪状态；
            System.out.println(name+":"+i);
        }
    }

    public static void main(String[] args) {
        ThreadYieldOne one=new ThreadYieldOne();
        ThreadYieldOne two=new ThreadYieldOne();
        Thread t1=new Thread(one);
        Thread t2=new Thread(two);
        t1.setPriority(Thread.MAX_PRIORITY);
        t2.setPriority(Thread.MIN_PRIORITY);
        one.name="one";
        two.name="two";
        System.out.println(t1);//打印第一个线程
        System.out.println(t2);//打印第二个线程
        t1.start();//启动第一个线程
        t2.start();//启动第二个线程
    }

}
